package com.glory.gloryquickui.adapter

import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.glory.gloryquickui.R
import com.glory.gloryquickui.entity.FieldBean
import com.glory.gloryquickui.entity.TablePortraitBaseCustomBean
import com.glory.gloryquickui.entity.TablePortraitCustomBean

/**
 *Created:YJ
 *创建时间：2021/5/8
 *Describe:
 */
//class TablePortraitAdapter(data: MutableList<TablePortraitCustomBean>?,) :
//    BaseSectionQuickAdapter<TablePortraitCustomBean, BaseViewHolder>(
//        R.layout.item_table_portrait_head,R.layout.item_table_portrait,
//        data) {
//
//    override fun convert(helper: BaseViewHolder, item: TablePortraitCustomBean) {
//        helper.setText(R.id.tvName, item.textName)
//        helper.setText(R.id.tvValue, item.textValue)
//    }
//
//    @SuppressLint("ResourceAsColor")
//    override fun convertHeader(helper: BaseViewHolder, item: TablePortraitCustomBean) {
//        helper.getView<View>(R.id.abc).setBackgroundColor(R.color.bg_gray)
//    }
//}

class TablePortraitAdapter(
    data: ArrayList<TablePortraitBaseCustomBean>?,
    val btnData: ArrayList<FieldBean>?, val tabButtonClickListener: TablePortraitButtonAdapter.TablePortraitButtonClickListener
):BaseQuickAdapter<TablePortraitBaseCustomBean,BaseViewHolder>(R.layout.item_table_portrait,data) {
    override fun convert(holder: BaseViewHolder, item: TablePortraitBaseCustomBean) {
        val descRv = holder.getView<RecyclerView>(R.id.descRv)
        val mLayoutManager = LinearLayoutManager(context)
        descRv.layoutManager = mLayoutManager
        val mAdapter = TablePortraitTextAdapter(item.tablelineData)
        descRv.adapter = mAdapter

        val btnRv = holder.getView<RecyclerView>(R.id.btnRv)
        btnRv.layoutManager = GridLayoutManager(context,3)
        val btnAdapter = TablePortraitButtonAdapter(btnData,tabButtonClickListener,holder.adapterPosition)
        btnRv.adapter = btnAdapter
    }
}